// File Name: beep_logic.c
// Author: kukukukuku~
// Date: 2024-06-25

#include "./User/Beep/inc/beep_logic.h"

/**
 * @brief   Beep警告
 * @param   xMs:    警告时间(ms)
 * @retval  None
 * @note    None
*/
void beep_alarm(uint16_t xMs)
{
    if(xMs < BEEP_ALARM_MIN)
    {
        xMs = BEEP_ALARM_MIN;
    }
    else if(xMs > BEEP_ALARM_MAX)
    {
        xMs = BEEP_ALARM_MAX;
    }
    
    beepOnMsCnt = xMs;
    
    beep_on();
    tmr_counter_enable(BEEP_TMR, FALSE);
    tmr_counter_value_set(BEEP_TMR, 0);
    tmr_flag_clear(BEEP_TMR, TMR_OVF_FLAG);
    tmr_counter_enable(BEEP_TMR, TRUE);
}
